package gui.newWindows;

import gui.Main.GUI;

import java.awt.Window;
import java.io.IOException;

import phase6.PortNumber;
import phase6.SegmentRunner;
import phase6.HyPeerWebSegmentThread;

public class CreateNewProcessPanel extends ChooseServerPanel
{

	public CreateNewProcessPanel(GUI main, Window window)
	{
		super(main, window);
	}

	protected void connectButtonPressed()
	{
		PortNumber port;
		try
		{
			port = new PortNumber(Integer.parseInt(portField.getText()));

		}
		catch (NumberFormatException e)
		{
			// TODO
			e.printStackTrace();
			port = new PortNumber(phase6.SegmentRunner.DEFAULT_PORT);
		}
		
		//TODO Create a new hypeerweb segment by starting a new thread and make sure it works
		//SegmentRunner
		//ProcessBuilder builder = new ProcessBuilder("");
		
		HyPeerWebSegmentThread segmentThread = new HyPeerWebSegmentThread(portField.getText(), ipField.getText());
		segmentThread.start();
		
		super.connectButtonPressed();
	}

}

